package com.intellij.licensecommon.util;

import org.jetbrains.rsa.GroupUtil;

import java.util.zip.CRC32;

public class LicenseUtil extends GroupUtil {
    public static final int a = 12;
    public static final int b = 14;

    public static short calcChecksum(String name, int id, byte[] bytes) {
        CRC32 crc32 = new CRC32();
        int j;
        if (name != null) {
            for (int i = 0; i < name.length(); i++) {
                j = name.charAt(i);
                crc32.update(j);
            }
        }
        crc32.update(id);
        crc32.update(id >> 8);
        crc32.update(id >> 16);
        crc32.update(id >> 24);
        for (int i = 0; i < bytes.length - 2; i++) {
            j = bytes[i];
            crc32.update(j);
        }
        return (short) (int) crc32.getValue();
    }
}

